import requests
from lxml import etree

if __name__ == "__main__":
    url = 'https://esf.0722fc.com/201911/662942/1.html'
    headers = {
        'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.81 Safari/537.36 SE 2.X MetaSr 1.0'
    }

    response = requests.get(url=url, headers=headers)
    response.encoding = response.apparent_encoding
    page_text = response.text
    # print(page_text)
    tree = etree.HTML(page_text)

    item = {}
    item['total_price'] = tree.xpath(
        '//div[@class="house-info mb20"]//span[@class="fz22 eszj"]/text()')[0]
    item['houseing_pattern'] = tree.xpath(
        '//div[@class="house-info mb20"]/ul/li[2]/i/text()')[0]
    item['unit_price'] = tree.xpath('//div[@class="house-info mb20"]/ul/li[4]/i/text()')[0]

    item['covered_area'] = tree.xpath('//div[@class="house-info mb20"]/ul/li[6]/i/text()')[0]

    item['construction_time'] = tree.xpath(
        '//div[@class="house-info mb20"]/ul/li[11]/i/text()')[0]
    item['decorate_class'] = tree.xpath('//div[@class="house-info mb20"]/ul/li[7]/i/text()')[0]
    item['house_category'] = tree.xpath('//div[@class="house-info mb20"]/ul/li[8]/i/text()')[0]
    item['orientation'] = tree.xpath('//div[@class="house-info mb20"]/ul/li[10]/i/text()')[0]
    item['address'] = tree.xpath('//div[@class="house-info mb20"]/ul/li[12]/i/text()')[0]
    item['floor'] = tree.xpath('//div[@class="house-info mb20"]/ul/li[9]/i/text()')[0]
    print(item)
